﻿package net.wangit.dev.wizard;

import java.util.List;

import net.wangit.dev.wizard.element.ABackButton;
import net.wangit.dev.wizard.element.AClearButton;
import net.wangit.dev.wizard.element.ADeleteActionButton;
import net.wangit.dev.wizard.element.AEUnit;
import net.wangit.dev.wizard.element.AEditLink;
import net.wangit.dev.wizard.element.ANewButton;
import net.wangit.dev.wizard.element.AQueryButton;
import net.wangit.dev.wizard.element.ASaveActionButton;
import net.wangit.dev.wizard.element.AScanLink;
import net.wangit.dev.wizard.unit.AFormUnit;
import net.wangit.dev.wizard.unit.AListUnit;
import net.wangit.dev.wizard.unit.APage;
import net.wangit.dev.wizard.unit.AQueryUnit;


public class TwoTableSuiteProcessor1 extends TwoTableSuiteProcessor {

	public TwoTableSuiteProcessor1() {
	}

	protected void createFathterTableUnits() throws Exception {
		APage.create(db, groupId, page1Id, page1Name);
		AEUnit.create(db, page1Id, queryUnitId, 11, true);
		AEUnit.create(db, page1Id, listUnitId, 21, false);
		AQueryUnit.create(db, groupId, queryUnitId, queryUnitName, 0, page1Id);
		List<String> elements = Table2Unit.create(db, queryUnitId,
				fatherTableName, 3, null);
		AQueryButton.create(db, ac, queryUnitId, WizardUtil.getUrl(domain,
				page1Id, "s"), elements);
		AClearButton.create(db, ac, queryUnitId, WizardUtil.getUrl(domain,
				page1Id, "s"), elements);
		AListUnit.create(db, domain, groupId, listUnitId, listUnitName,
				fatherTableName, queryUnitId, null, true, 0, true, page1Id);
		elements = Table2Unit.create(db, listUnitId, fatherTableName, 2, null);
		ANewButton.create(db, ac, listUnitId, elements, WizardUtil.getNewUrl(
				domain, page2Id));
		String command = WizardUtil.getFatherSonDeleteCommand(fatherTableName,
				listUnitId, sonTableName, linkedFields);
		ADeleteActionButton.create(db, ac, domain, 2, listUnitId,
				fatherTableName, command, WizardUtil.getUrl(domain, page1Id,
						"s"), elements);
		AScanLink.create(db, ac, domain, listUnitId, page2Id, formUnitId,
				fatherTableName, elements);
		AEditLink.create(db, ac, domain, listUnitId, page2Id, formUnitId,
				fatherTableName, elements);
		AFormUnit.create(db, domain, groupId, formUnitId, formUnitName,
				fatherTableName, 0, page2Id);
		elements = Table2Unit.create(db, formUnitId, fatherTableName, 1, null);
		ABackButton.create(db, ac, formUnitId, WizardUtil.getUrl(domain,
				page1Id, "s"), elements);
		String forward = WizardUtil.getUrl(domain, page2Id, "e");
		ASaveActionButton.create(db, ac, formUnitId, fatherTableName, forward,
				elements, sonListUnitId, sonTableName, son2FatherFields);
	}

	protected String[][] getUnits() {
		return (new String[][] { new String[] { page1Id, "page1id" },
				new String[] { queryUnitId, "queryunitid" },
				new String[] { listUnitId, "listunitid" },
				new String[] { page2Id, "page2id" },
				new String[] { formUnitId, "formunitid" },
				new String[] { sonListUnitId, "sonlistunitid" } });
	}
}
